import request from '@/utils/request';

const Form_BASE_URL = '/nljs/form';

const FormAPI = {
  /************** 表单分类 **************/
  // 新增表单分类
  addFormCategory(data: any) {
    return request({
      url: `${Form_BASE_URL}/category`,
      method: 'post',
      data,
    });
  },
  // 修改表单分类
  editFormCategory(data: any) {
    return request({
      url: `${Form_BASE_URL}/category/update`,
      method: 'post',
      data,
    });
  },
  // 删除表单分类
  delForm(id: string | number) {
    return request({
      url: `${Form_BASE_URL}/category/delete/${id}`,
      method: 'post',
    });
  },
  // 分页查询表单分类
  getFormList(data: any) {
    return request({
      url: `${Form_BASE_URL}/category/page`,
      method: 'get',
      params: data,
    });
  },
  // 查询表单分类列表 无分页
  getFormCategoryList(data?: any) {
    return request({
      url: `${Form_BASE_URL}/category/list`,
      method: 'get',
      params: data,
    });
  },
  // 获取表单分类详情
  getBatchDetail(id: string | number) {
    return request({
      url: `${Form_BASE_URL}/category/${id}`,
      method: 'get',
    });
  },
  // 批量删除表单分类
  batchDel(data: object) {
    return request({
      url: `${Form_BASE_URL}/category/batch-delete`,
      method: 'post',
      data,
    });
  },

  /************** 表单分类下属表单定义 **************/
  // 新增表单定义
  addFormDefinition(data: any) {
    return request({
      url: `${Form_BASE_URL}/definition`,
      method: 'post',
      data,
    });
  },
  // 修改表单定义
  editFormDefinition(data: any) {
    return request({
      url: `${Form_BASE_URL}/definition/update`,
      method: 'post',
      data,
    });
  },
  // 删除表单定义
  delFormDefinition(id: string | number) {
    return request({
      url: `${Form_BASE_URL}/definition/delete/${id}`,
      method: 'post',
    });
  },
  // 分页查询表单定义
  getDefinitionList(data: any) {
    return request({
      url: `${Form_BASE_URL}/definition/page`,
      method: 'get',
      params: data,
    });
  },
  // 查询表单定义列表 无分页
  getDefinitionAllList(data?: any) {
    return request({
      url: `${Form_BASE_URL}/definition/list`,
      method: 'get',
      params: data,
    });
  },
  // 获取表单定义详情
  getDefinitionDetail(id: string | number) {
    return request({
      url: `${Form_BASE_URL}/definition/${id}`,
      method: 'get',
    });
  },
  // 批量删除表单分类
  batchDefDel(data: number[] | string[]) {
    return request({
      url: `${Form_BASE_URL}/definition/batch-delete`,
      method: 'post',
      data,
    });
  },
  // 根据分类ID获取表单定义列表
  getListByCategoryId(categoryId: string | number) {
    return request({
      url: `${Form_BASE_URL}/definition/listByCategoryId/${categoryId}`,
      method: 'get',
    });
  },
  // 获取批次下的表单id
  getBatchFormIds(batchId: string | number) {
    return request({
      url: `/nljs/report/batch/forms/${batchId}`,
      method: 'get',
    });
  },
};

export default FormAPI;
